﻿<%@page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<html xmlns="http://www.w3.org/1999/xhtml">

<%@page import="java.util.List" %>
<%@page import="java.util.ArrayList" %>
<%@page import="nc.bs.ebvp.prodpricemaintain.form.SingleProdPriceForm" %>

<%
	String basePath = request.getContextPath();
%>

<%
	String i = "1";
%> 

<head>
    <title>产品价格维护</title>
    
    <script language="javascript" type="text/javascript">
    		
            var price_digit = 8;
	    	//删除
	    	function deletePrice(){

	    		//判断编辑行是否被选中
	    		var isCommitedArray = document.getElementsByName("isCommited");
	    		for(var i=0; i<isCommitedArray.length; i++){
					if(isCommitedArray[i].checked == true){
						break;
					}
		    	}
	    		//都没有选中的，抛提示
	    		if(i==isCommitedArray.length){
	    			alert("请选中要删除的行!");
	    			return;
	    		}
	    	     
	    	   var b = window.confirm("是否删除所选产品价格?");
	    	   if(b == true){  //确定要删
					 
					 //后台删除--ajax提交删除
					 var formStr = $('#productListForm').serialize();
					 var bodyContent = $.ajax(
					 	{ 
				            url: "<%=basePath%>/prodprice/deletePriceBatch",  
				            type: "POST", 
				            data: "&" + formStr, 
				            dataType: "text", 
				            async:false, 
				            success: function(msg){
					             
		                 	} 
		              	} 
	    	    	)

	    	    	for(var x=0; x<isCommitedArray.length; x++){
						if(isCommitedArray[x].checked == true){
							$(isCommitedArray[x]).parents("tr").remove();
						}
					} 

	    	    }else{  //取消删除
	    	     	return;
	    	    }    	       	
	    	}
	    	
	    	//批量导出
	    	function batchExport2Xls(){
	    		//判断是否选中
	    		var isCommitedArray = document.getElementsByName("isCommited");
	    		for(var i=0; i<isCommitedArray.length; i++){
					if(isCommitedArray[i].checked == true){
						break;
					}
		    	}
	    		//都没有选中的，抛提示
	    		if(i==isCommitedArray.length){
	    			alert("请选中要导出的行!");
	    			return;
	    		}else{
	    			document.productListForm.action = "<%=basePath%>/prodprice/export2xls";
	    			document.productListForm.submit();
	    		}
	    	}
	    	
	    	function trimmawl(strToTrim) { 
		        result=strToTrim 
		        for (_i=0; _i<strToTrim.length; _i++) { 
		                if (strToTrim.charAt(_i)==" ") result=strToTrim.substr(_i+1) 
		                else _i=strToTrim.length 
		        } 
		        strToTrim=result 
		        for (_i=strToTrim.length-1; _i>=0; _i--) { 
		                if (strToTrim.charAt(_i)==" ") result=strToTrim.substr(0,_i) 
		                else _i=0 
		        } 
	       		return result 
			} 
	
	    	//查询产品价格信息
	    	function qryProdPriceData(){
	    		document.prodQueryForm.action="<%=basePath%>/prodprice/queryprodpricebycond";
	    		document.prodQueryForm.submit();
	        } 
	
			//下一页
			function nextPage(){
				document.prodQueryForm.action="<%=basePath%>/prodprice/queryprodpricebycond";
				document.getElementById("pageno").value="${PAGEINFO.pDownIndex}";
	    		document.prodQueryForm.submit();
			}
		   //上一页
		   function lastPage(){
			   document.prodQueryForm.action="<%=basePath%>/prodprice/queryprodpricebycond";
			   document.getElementById("pageno").value="${PAGEINFO.pUpIndex}";
	   		   document.prodQueryForm.submit();
		   }
		   //第n页
		   function nPage(n){
			   document.prodQueryForm.action="<%=basePath%>/prodprice/queryprodpricebycond";
			   document.getElementById("pageno").value=n;
	   		   document.prodQueryForm.submit();		   
		   }  	 
	

    	//添加产品价格
    	function addProdPrice(){
    		var title = "添加产品";
    		var url = "url:post?<%=basePath%>/prodprice/addprod";
			dialog(title, url,"500", "auto", "", "");
    	}
    	
    	//修改
    	function modifyPriceDetail(no){
    		var trNode =$(no).parents("tr");
        	var current_trid=trNode.attr("id");
        	var target_trid=trNode.attr("targetid");
    		//初始化 单位、币种、生产厂商、运输方式
        	//初始化 单位和生产厂商
        	var targetEditNode = $('#'+target_trid);
        	
        	initUnitAndManufacureWhenModify(targetEditNode);
        	//初始化 币种
        	initCurrencyWhenModify(targetEditNode);
        	//初始化 运输方式
        	initTransportWhenModify(targetEditNode);
        				
    		//隐藏浏览行
        	$('#'+target_trid).show(); 	
        	//隐藏前,如果checkbox打勾,则清空
    		if($('#'+current_trid).find("#isCommited").attr("checked")==true){
        		$('#'+current_trid).find("#isCommited").attr("checked", "");
        	}				
			$('#'+current_trid).hide();
		} 

		//保存
    	function savePriceDetail(no){
    		var formNode =$(no).parents("form");
    		//校验第一步：检查必输
    		var ErrMsg = "";
    		var lineErrMsg = "";
    		//单位
    		var jUnitVal = formNode.find("#pk_unit").val();
    		if(jUnitVal==null || trimmawl(jUnitVal)==""){
    			lineErrMsg += "[单位]";
    		}
    		//币种
    		var jCurrency = formNode.find("#pk_currency").val();
    		if(jCurrency==null || trimmawl(jCurrency)==""){
    			lineErrMsg += "[币种]";
    		}
    		//含税单价
    		var jUnitPrice = formNode.find("#tax_unit_price").val();
    		if(jUnitPrice==null || trimmawl(jUnitPrice)==""){
    			lineErrMsg += "[含税单价]";
    		}
    		//无税单价
    		var jTaxFreeUnitPrice = formNode.find("#tax_free_unit_price").val();
    		if(jTaxFreeUnitPrice==null || trimmawl(jTaxFreeUnitPrice)==""){
    			lineErrMsg += "[无税单价]";
    		}
    		//税率
    		var jTaxRate = formNode.find("#tax_rate").val();
    		if(jTaxRate==null || trimmawl(jTaxRate)==""){
    			lineErrMsg += "[税率]";
    		}
    		//生效日期
    		var jValidDate = formNode.find("input[name='valid_date']").val();
    		if(jValidDate==null || trimmawl(jValidDate)==""){
    			lineErrMsg += "[生效日期]";
    		}
    		//失效日期
    		var jInValidDate = formNode.find("input[name='invalid_date']").val();
    		if(jInValidDate==null || trimmawl(jInValidDate)==""){
    			lineErrMsg += "[失效日期]";
    		}
    		
    		if(lineErrMsg != ""){
    			lineErrMsg = "下列字段不允许为空:" + lineErrMsg + ",请填写完整!\n";
    			ErrMsg += lineErrMsg;
    		}

    		//校验第二步：输入数字是否合法
    		var inValidNumErr = "";
    		if(isNaN(jUnitPrice)){
    			inValidNumErr+= "[含税单价]";
        	}
        	if(isNaN(jTaxFreeUnitPrice)){
        		inValidNumErr+="[无税单价]";
            }
            if(isNaN(jTaxRate)){
            	inValidNumErr+="[税率]";
            }
			if(inValidNumErr !=""){
				inValidNumErr += "不是有效数值!\n";
				ErrMsg += inValidNumErr;
			}
    		//校验第三步：生效日期、失效日期是否合法
    		var inValidDateErr = "";
			var vDate = formNode.find("input[name='valid_date']").val().replace("-", "/");
			var invDate = formNode.find("input[name='invalid_date']").val().replace("-", "/");
			var date1 = new Date(Date.parse(vDate));
			var date2 = new Date(Date.parse(invDate));
			if(date1 > date2){
				inValidDateErr += "失效日期不允许早于生效日期!";
				ErrMsg +=inValidDateErr;
			}
			if(ErrMsg != ""){
				alert(ErrMsg);
				return;
			}
				
    		 var formStr = formNode.serialize();
			 var bodyContent = $.ajax(
				{ 
		            url: "<%=basePath%>/prodprice/submitprice",  
		            type: "POST", 
		            data: "&" + formStr, 
		            dataType: "text", 
		            async:false, 
		            success: function(msg){ 
			            if(msg == 'NULL'){
							alert("保存该行数据失败");
					    }else{
							alert("保存成功");  

							var trNode =$(no).parents("tr");
				        	var current_trid=trNode.attr("id");
				        	var target_trid=trNode.attr("targetid");
				        	$('#'+target_trid).show(); 
				        	if($('#'+current_trid).find("#isCommited").attr("checked")==true){
				        		$('#'+current_trid).find("#isCommited").attr("checked", "");
				        	}					
							$('#'+current_trid).hide();
							
							//刷新浏览行
							var retValueArray = msg.split("|");
							
							$('#'+ current_trid).find("#primaryKey").val(retValueArray[16]);
							$('#'+ current_trid).find("#isCommited").val(retValueArray[16]);
							$('#'+ target_trid).find("#isCommited").val(retValueArray[16]);
	
							if(retValueArray[4] != null && retValueArray[4]!="null" && trimmawl(retValueArray[4])){
								$('#'+target_trid).find("#hide_unit").text("单位:" + retValueArray[4]);
							}else{
								$('#'+target_trid).find("#hide_unit").text("");
							}
							if(retValueArray[6] != null && retValueArray[6]!="null" && trimmawl(retValueArray[6])){
								$('#'+target_trid).find("#hide_currency_name").text("币种:"+retValueArray[6]);
							}
							$('#'+target_trid).find("#hide_tax_unit_price").html("<font class='words-red-bold'>"+retValueArray[7]+"</font>");
							$('#'+target_trid).find("#hide_tax_free_unit_price").html("<font class='words-red-bold'>"+retValueArray[8]+"</font>");
							$('#'+target_trid).find("#hide_tax_rate").html("<font class='words-red-bold'>"+retValueArray[9]+"</font>");
							$('#'+target_trid).find("#hide_valid_date").html("<font class='words-blue'>"+retValueArray[10]+"</font>");
							$('#'+target_trid).find("#hide_invalid_date").html("<font class='words-blue'>"+retValueArray[11]+"</font>");
							
							if(retValueArray[13] != null && retValueArray[13]!="null" && trimmawl(retValueArray[13])){
								$('#'+target_trid).find("#hide_manufactory_name").html("生产厂商:"+retValueArray[13]);
							}else{
								$('#'+target_trid).find("#hide_manufactory_name").html("");
							}
							if(retValueArray[15] != null && retValueArray[15]!="null" && trimmawl(retValueArray[15])){
								$('#'+target_trid).find("#hide_transport_type").html("运输方式:" + retValueArray[15]);
							}else{
								$('#'+target_trid).find("#hide_transport_type").html("");
							}
						}
                 	} 
                 } 
              )

		}

        //初始化单位
    	function initUnitAndManufacureWhenModify(trNode){
    		//从父窗口取pk_prod_v
    		var pk_prod_v_value = "";
			var pk_prod_v_ele = trNode.find('#pk_prod_v');//document.getElementById("pk_prod_v" + row_no);
			if(pk_prod_v_ele != null){
				pk_prod_v_value = pk_prod_v_ele.val();
			}
    		var myts = new Date();
            jQuery.ajax
            (
                	{	
                		type: "GET", 
                    	async:false, 
                   		url:"<%=basePath%>/prodprice/queryUnitByPkProdV?pk_prod_v="+ pk_prod_v_value +"&myts="+myts, 
                   		dataType:"text", 
                    	success:function(result)
                    	{ 
                        	var ele_pk_unit= trNode.find('#pk_unit'); //document.getElementById("pk_unit" + row_no);
                        	if(result == 'NULL'){
                        		ele_pk_unit.empty();
                    		}else{
                    			
                    			var unitArray = eval("("+result+")");
                    			var unitValue = trNode.find('#pk_unit').val();//document.getElementById("pk_unit" + row_no).value;
                    			ele_pk_unit.empty();
                    			for(var index=0; index<unitArray.length; index++){
                    				var obj = unitArray[index];							       
							        if(unitValue==obj.pk_unit){
							        	 ele_pk_unit.append("<option value='"+obj.pk_unit+"' selected>"+obj.name+"</option>");
									}else{
										 ele_pk_unit.append("<option value='"+obj.pk_unit+"'>"+obj.name+"</option>");
									}
                    			}
                    		}                    	
	                    } 
               	 	} 
            ) 
            
            jQuery.ajax
            (
                	{	
                		type: "GET", 
                    	async:false, 
                   		url:"<%=basePath%>/prodprice/queryManufactureByPkProdV?pk_prod_v="+ pk_prod_v_value +"&myts="+myts, 
                   		dataType:"text", 
                    	success:function(result1)
                    	{ 
                    		var ele_pk_manufactory = trNode.find('#pk_manufactory');//document.getElementById("pk_manufactory" + row_no);
                    		if(result1 == 'NULL'){
                    			ele_pk_manufactory.empty();
                    		}else{
                    			
                        		var manufValue = trNode.find('#pk_manufactory').val();//document.getElementById("pk_manufactory" + row_no).value;
                    			var manufactArray = eval("("+result1+")");
                    			ele_pk_manufactory.empty();
                    			for(var index=0; index<manufactArray.length; index++){
                    				var obj = manufactArray[index];
							        if(manufValue == obj.pk_manufacture){
							        	ele_pk_manufactory.append("<option value='"+obj.pk_manufacture+"' selected>"+obj.name+"</option>");
								    }else{
								    	ele_pk_manufactory.append("<option value='"+obj.pk_manufacture+"'>"+obj.name+"</option>");
								    }
                    			}
                    		}                    	
	                    } 
              	 	} 
            ) 
              		
    	}
    	
		
		function initCurrencyWhenModify(trNode){
			var myts = new Date();
            jQuery.ajax
            (
                {	
                	type: "GET", 
                    async:false, 
                   	url:"<%=basePath%>/prodprice/queryCurrency?myts="+myts, 
                   	dataType:"text", 
                    success:function(result)
                    {
                    	var ele_pk_currency = trNode.find('#pk_currency');//document.getElementById("pk_currency" + row_no);
                    	if(result == 'NULL'){
                    		ele_pk_currency.empty();
                        }else{
                        	
                            var cnyValue = ele_pk_currency.val();
                    		var cnyArray = eval("("+result+")");
                    		ele_pk_currency.empty();
                    		for(var index=0; index<cnyArray.length; index++){
                    			var obj = cnyArray[index];
                    			if(cnyValue == obj.pk_currtype){
						        	ele_pk_currency.append("<option value='"+obj.pk_currtype+"' selected>"+obj.name+"</option>");
							    }else{
							    	ele_pk_currency.append("<option value='"+obj.pk_currtype+"'>"+obj.name+"</option>");
							    }
                    		}
                    	}                			                 	
	                } 
               	 } 
            ) 
		}
        
        function initTransportWhenModify(trNode){
			var myts = new Date();
            jQuery.ajax
            (
                {	
                	type: "GET", 
                    async:false, 
                   	url:"<%=basePath%>/prodprice/queryTransport?myts="+myts, 
                   	dataType:"text", 
                    success:function(result)
                    {
                    	var ele_pk_transport= trNode.find('#pk_transport_type');//document.getElementById("pk_transport_type" + row_no);
                    	if(result == 'NULL'){
                    		ele_pk_transport.empty();
                    	}else{
                    	
                        	var transpVal = ele_pk_transport.val();
                    		var transportArray = eval("("+result+")");
                    		ele_pk_transport.empty();
                    		for(var index=0; index<transportArray.length; index++){
                    				var obj = transportArray[index];
							        if(transpVal == obj.pk_transporttype){
							        	ele_pk_transport.append("<option value='"+obj.pk_transporttype+"' selected>"+obj.name+"</option>");
								    }else{
								    	ele_pk_transport.append("<option value='"+obj.pk_transporttype+"'>"+obj.name+"</option>");
								    }
                    		}

                    		
                    	}                			                 	
	                } 
               	 } 
            ) 
		}

        function doCalPrice(changeKey, eleObj){

			var trNode =$(eleObj).parents("tr");
			var current_trid=trNode.attr("id");
        	var targetEditNode = $('#'+current_trid);

        	var taxprice = targetEditNode.find('#tax_unit_price').val();
        	var notaxprice = targetEditNode.find('#tax_free_unit_price').val();
			var taxrate = targetEditNode.find('#tax_rate').val();
        	
			//物料主健
			document.calpriceform.pk_prod_cal.value = targetEditNode.find('#pk_prod_v').val();
			//报价单位
			document.calpriceform.pk_unit_cal.value = targetEditNode.find('#pk_unit').val();
			//币种
			document.calpriceform.pk_currency_cal.value = targetEditNode.find('#pk_currency').val();
			//含税单价
			document.calpriceform.has_tax_price_cal.value = taxprice;
			//无税单价
			document.calpriceform.no_tax_price_cal.value = notaxprice;
			//税率
			document.calpriceform.tax_rate_cal.value = taxrate;

			//共三个字段，当两个为空时不计算
			if(changeKey == "has_tax_price"){
				//如果当前编辑值被清空，不触发计算
				if(taxprice==null || trimmawl(taxprice)=="" || trimmawl(taxprice)=="null"){
					return;
				}else{
					if( (notaxprice==null || trimmawl(notaxprice)=="" || trimmawl(notaxprice)=="null") 
							 && (taxrate==null || trimmawl(taxrate)=="" || trimmawl(taxrate)=="null")
							){
							return;
						}
				}
			}
			if(changeKey == "no_tax_price"){
				if(notaxprice==null || trimmawl(notaxprice)=="" || trimmawl(notaxprice)=="null"){
					return;
				}else{
					if( (taxprice==null || trimmawl(taxprice)=="" || trimmawl(taxprice)=="null") 
							 && (taxrate==null || trimmawl(taxrate)=="" || trimmawl(taxrate)=="null")
							){
							return;
					}
				}
			}
			if(changeKey == "tax_rate"){
				if(taxrate==null || trimmawl(taxrate)=="" || trimmawl(taxrate)=="null"){
					return;
				}else{
					if( (taxprice==null || trimmawl(taxprice)=="" || trimmawl(taxprice)=="null") 
							 && (notaxprice==null || trimmawl(notaxprice)=="" || trimmawl(notaxprice)=="null")
					  ){
							return;
					}
				}
			}
			//触发计算的字段为: changeKey
			document.calpriceform.property_cal.value= changeKey;
			//设置参数:无税优先，其他参数不设置，用默认值
			document.calpriceform.isTaxPrior.value="false"; 
			//行号
			//document.calpriceform.row_no.value = index;
    		var formStr = $('#calpriceform').serialize();
			var bodyContent = $.ajax(
				{ 
		            url: "<%=basePath%>/sourcing/biddingprojlist/calprice",  
		            type: "POST", 
		            data: "&" + formStr, 
		            dataType: "text", 
		            async:false, 
		            success: function(responseText){ 
						showResponse2(responseText, eleObj);
                 	} 
                 } 
            )
		}
		
		function showResponse2(responseText, eleObj) {
			// 0:报价数量|1:税率|2:折扣率|3:含税单价|4:价税合计|5:含税净价|6:主含税净价|7:无税单价|8:无税金额|9:无税净价|10:主无税净价|11:税e|12:行号|13:换算率|14:主数量
			var responseArr = responseText.split("|");
			var index = responseArr[12];

			var trNode =$(eleObj).parents("tr");
			var current_trid=trNode.attr("id");
        	var targetEditNode = $('#'+current_trid);

			//含税单价
			var hasTaxPrice = targetEditNode.find('#tax_unit_price');
			if(responseArr[3] != null &&responseArr[3]!="null" && trimmawl(responseArr[3])!=""){
				hasTaxPrice.val(responseArr[3]);
			}else{
				hasTaxPrice.val(" ");
			}
			subReduNumMwl(hasTaxPrice, price_digit);
						
			//无税单价
			var noTaxPrice = targetEditNode.find('#tax_free_unit_price');
			if(responseArr[7]!=null && responseArr[7]!="null" && trimmawl(responseArr[7])!=""){
				noTaxPrice.val(responseArr[7]);
			}else{
				noTaxPrice.val(" ");
			}
			subReduNumMwl(noTaxPrice, price_digit);
			
			//税率
			var taxRate = targetEditNode.find('#tax_rate');
			if(responseArr[1]!=null && responseArr[1]!="null" && trimmawl(responseArr[1])!=""){
				taxRate.val(responseArr[1]);
			}else{
				taxRate.val(" ");
			}
			subReduNumMwl(taxRate, 2);
		}


		//初始化价格精度
		function initPriceDigit(){
			var myts = new Date();
            jQuery.ajax
            (
                {	
                	type: "GET", 
                    async:false, 
                   	url:"<%=basePath%>/prodprice/queryPriceScaleDigit?myts="+myts, 
                   	dataType:"text", 
                    success:function(result)
                    {
                    	price_digit = result;
	                } 
               	 } 
            ) 
		}


		//截去多余的小数位数或者补足小数位
		function subReduNumMwl(obj,intPrecision){
			var strValue = obj.val();
			if(isNaN(strValue)){
				return;
			}
			if(strValue == null || strValue == ""){
				return;
			}
			if (strValue.indexOf(".") != -1){
				var values = strValue.split(".");
				if(values[1].length > intPrecision){
					if(intPrecision > 0){
						strValue = values[0] + "." + values[1].substring(0,intPrecision);
						strValue = roundNum(strValue,values[1].substring(intPrecision),intPrecision);
					}else{
						strValue = values[0];
					}
				}else{
					for(var i=values[1].length;i<intPrecision;i++){
						strValue += "0";
					}
				}
			}else{
				if(intPrecision > 0){
					strValue += ".";
					for(var i=0;i<intPrecision;i++){
						strValue += "0";
					}
				}
			}
			obj.val(strValue);
		}
      </script>
</head>

<body class="fullbody" onload='initPriceDigit();'>
           <div class="context">
			<div class="position">
				<div class="tposi">
					当前位置：
					<a href="javascript:changeMenu(1,'<%=request.getContextPath()%>/infopub/pubmain?menuid=1');" class="linkstyle">首页</a>&nbsp;&gt;&gt;&nbsp;
					<a href="javascript:changeMenu(4,'');" class="linkstyle">自助服务</a>&nbsp;&gt;&gt;&nbsp;
					<span class="curposition">产品价格维护 </span>
				</div>
				<div class="help">
                	<a href="javascript:void(null);" onclick="doHelp('<%=request.getContextPath()%>/help/html/CPJGWH.html');" class="linkstyle">帮助</a>
              	</div>
			</div>
			<div class="margin8">
			</div>
			<div class="subpage_title">
                <div class="title_index">
                        <img src="<%=basePath%>/images/common/dot03.gif" alt="" border="0" />&nbsp;产品价格维护 </div>
                </div>
                    <div class="margin10">
                    </div>
                    
                     <div class="subpage_search" >
                    	<form name="prodQueryForm" id="prodQueryForm" method="post">
                      		<table border="0" cellpadding="0" cellspacing="0" class="searchtable">
	                            <tr>
	                                <td valign="middle" class="w_1">产品分类名称：</td>
	                                <th valign="middle" class="w_2">
	                                    <input type="text" class="searchtext" name="qryProdCateName"  value="${QUERY_FORM.qryProdCateName}"  />
	                                </th>
	                                <td valign="middle" class="w_1">产品名称：</td>
	                                <th valign="middle" class="w_2">
	                                   <input type="text" class="searchtext" name="qryProdName"  value="${QUERY_FORM.qryProdName}"  />
	                                   <input type="hidden" name="pageno" id="pageno" value="" /> 
	                                </th>
	                            </tr>
	                            <tr>
	                            </tr>
	                            <tr>
	                                <td valign="middle" colspan="4" align="center">
	                                    <input type="button" class="btnscs" value="查询" onclick="qryProdPriceData()"/>&nbsp;&nbsp;
	                                    <input type="reset" class="btnscs" value="取消" />
	                                </td>
	                            </tr>
	                        </table>
                        </form>
                    </div>
                                        
                    
               <div class="productlist">
					<form name="productListForm" id="productListForm" action="" method="post">			
	                   	<table id="productListTable" cellpadding="0" cellspacing="0" class="tableCss" >
		                            <tr class="titleTr" id="titleId">
		                            	<th width='28'>
		                            		选中
		                            	</th>
		                                <th width='170'>
		                                   	 产品
		                                </th>
		                                <th width='124'>
		                                   	单位/币种
		                                </th>
		                                <th width='130'>
		                                  	 价格
		                                </th>
		                                <th width='140'> 
		                                   	 生效失效日期
		                                </th>
		                                <th width='168'>
		                                 	 备注
		                                </th>
		                                <th class="th1" width="40">
		                                  	  维护
		                                </th>	                               
		                            </tr>
	                        	<%
	                        		int j = 0;
	                        		SingleProdPriceForm form = null;
	                        	%>
								<c:if test="${PROD_PRICE_SFORM_LIST != null}">
									<c:forEach items="${PROD_PRICE_SFORM_LIST}" var="item">
										<%
										if (j % 2 == 1) {
										%>
										<tr class="contTr-old" id="trid_<%=j+1%>" style="display: none;"  targetid="hide_trid_<%=j+1%>" >
										<%
										} else {
										%>
										<tr class="contTr-even"  id="trid_<%=j+1%>" style="display: none;"  targetid="hide_trid_<%=j+1%>">
										<%
										}
										%>
											<td class="td1">
												<input type="checkbox" name="isCommited" id="isCommited" value="${item.primaryKey}" />
											</td>
											<td	class="td1">
												<span class="prodName">${item.prod_name}</span><br/>
												<c:if test="${item.module!=null}">规格：${item.module}<br/></c:if>
												<c:if test="${item.type!=null}">型号：${item.type}</c:if>
											</td>
											<td	class="td1">
												单位:<select name="pk_unit" id="pk_unit" >
														<option value="${item.pk_unit}" selected>${item.unit}</option>
		        									</select>
		        								<br/>
												币种:<select name="pk_currency" id="pk_currency" >
														<option value="${item.pk_currency}" selected>${item.currency_name}</option>
													</select>
											</td>
											<td	class="td1">
												含税单价:<input name="tax_unit_price" id="tax_unit_price" type="text" value="${item.tax_unit_price}" class="input-edit"  onkeypress="javascript:keyPress(this);" onchange="subReduNum(this,${PRICE_DIGIT});javascript:doCalPrice('has_tax_price', '<%=j+1%>');"/> <br/>
												无税单价:<input name="tax_free_unit_price" id="tax_free_unit_price" type="text" value="${item.tax_free_unit_price}" class="input-edit" onkeypress="javascript:keyPress(this);" onchange="subReduNum(this,${PRICE_DIGIT});javascript:doCalPrice('no_tax_price', '<%=j+1%>');"/><br/>
												税&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;率:<input name="tax_rate" id="tax_rate" type="text" value="${item.tax_rate}" class="input-edit" onkeypress="javascript:keyPress(this);" onchange="subReduNum(this,2);javascript:doCalPrice('tax_rate', '<%=j+1%>');"/> 
											</td>
											<td	class="td1">
												生效日期:<input name="valid_date" id="valid_date<%=j+1%>"  type="text" value="${item.valid_date}"
													onclick="return showCalendar('valid_date<%=j+1%>', 'y-mm-dd')" readonly="readonly" class="searchdateformwl"/>
												<br/>
												失效日期:<input name="invalid_date" id="invalid_date<%=j+1%>" type="text" value="${item.invalid_date}"
                									onclick="return showCalendar('invalid_date<%=j+1%>', 'y-mm-dd')" 
													readonly="readonly" class="searchdateformwl"  />
											</td>
											<td	class="td1">
												生产厂商:<select name="pk_manufactory" id="pk_manufactory" >
															<option value="${item.pk_manufactory}" selected >${item.manufactory_name}</option>
		                								</select>
		                						        <br/>
												运输方式:<select name="pk_transport_type" id="pk_transport_type" >
															<option value="${item.pk_transport_type}" selected>${item.transport_type}</option>
													    </select>
											</td>
											<td	class="td1" >
												<label class='linkstyle3' onclick='savePriceDetail(this)' >保存</label>
												<!-- 下面是隐藏字段 -->
												<input name="primaryKey" id="primaryKey" type="hidden" value="${item.primaryKey}" />
												<input name="prod_cate_pk" id="prod_cate_pk" type="hidden" value="${item.prod_cate_pk}" />
												<input name="pk_prod_v" id="pk_prod_v" type="hidden" value="${item.pk_prod_v}" />
											</td>
										</tr>										
										<script language="javascript" type="text/javascript">
											$('#trid_<%=j+1%>').wrap("<form id='form_<%=j+1%>'></form>");  
										</script>
										<!--  以下为隐藏tr的处理--> 
											<%
										if (j % 2 == 1) {
										%>
										<tr class="contTr-old" id="hide_trid_<%=j+1%>"   targetid="trid_<%=j+1%>">
										<%
										} else {
										%>
										<tr class="contTr-even"  id="hide_trid_<%=j+1%>"  targetid="trid_<%=j+1%>">
										<%
										}
										%>
											<td class="td1"> 
												<input type="checkbox" name="isCommited" id="isCommited" value="${item.primaryKey}" />
											</td>
											<td	class="td1">
												<span class="prodName">${item.prod_name}</span><br/>
												<c:if test="${item.module!=null}">规格：${item.module}<br/></c:if>
												<c:if test="${item.type!=null}">型号：${item.type}</c:if>
											</td>
											<td	class="td1">
												<span id="hide_unit" >单位: ${item.unit}</span> 
		        								<br/>
												<span  id="hide_currency_name" >币种:${item.currency_name}</span>
											</td>
											<td	class="td1">
												含税单价:<span id="hide_tax_unit_price" ><font class='words-red-bold'>${item.tax_unit_price}</font></span><br/>
												无税单价:<span id="hide_tax_free_unit_price" ><font class='words-red-bold'>${item.tax_free_unit_price}</font></span><br/>
												税&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;率:<span id="hide_tax_rate"><font class='words-red-bold'>${item.tax_rate}</font></span> 
											</td>
											<td	class="td1">
												生效日期:<span id="hide_valid_date"><font class='words-blue'>${item.valid_date}</font></span>
												<br/>
												失效日期:<span id="hide_invalid_date"><font class='words-blue'>${item.invalid_date}</font></span> 
											</td>
											<td	class="td1">
												<c:if test="${item.manufactory_name!=null}"><span id="hide_manufactory_name" >生产厂商:${item.manufactory_name}</span><br/></c:if>
												<c:if test="${item.transport_type!=null}"><span id="hide_transport_type">运输方式:${item.transport_type}</span></c:if> 
											</td>
											<td	class="td1" >
												<label class='linkstyle3' onclick='modifyPriceDetail(this)' >修改</label>
											</td>											 
										</tr>
																				
										<%
											j++;
										%>
										
									</c:forEach>
								</c:if>
						</table> 
	                        <table border="0" class="tableCss" >
	                        	<tr>
	                                <td colspan="21">
	                                    &nbsp;
	                                    <img alt="" src="<%=basePath%>/images/common/add.png" border="0" />&nbsp;
	                                    <label class="linkstyle3" onclick="addProdPrice()" ondblclick="addProdPrice()">增加产品价格</label>
	                                </td>
	                            </tr>
	                           	
	                           	<c:if test="${ERROR_MSG != null}">
	                           		<tr>
	                            	 <td colspan="21" align="center">
	                            	 	<font color="red">
		                            	 	<c:out value="!${ERROR_MSG}">
		                            	 	</c:out>
	                            	 	</font>
	                            	 </td>
	                           		</tr>
	                           	</c:if>
	                            
	                        </table>                       
                        </form>    
              <div class="subpage_pager">
                        <table border="0">
                            <tr style="font-size:12px;">
                                <c:if test="${false == PAGEINFO.pUpIsUsed}">
									<td class="pageindexn">
                                    	&lt;上一页
                               		</td>
								</c:if>
								<c:if test="${true == PAGEINFO.pUpIsUsed}">
								    <td class="pageindexn">
                                    	<a href="javascript:lastPage()">&lt;上一页</a>
                               		</td>
								</c:if>
                                
                                <c:forEach items="${PAGEINFO.currPageBtnList}" var="pagebtn">
									<c:if test="${pagebtn.pageIndex == PAGEINFO.currPageIndex}">
										 <td class="pageindex">
                                   			<a href="javascript:void(null)" >${pagebtn.showPageCode}</a>
                               			 </td>
									</c:if>
									<c:if test="${pagebtn.pageIndex != PAGEINFO.currPageIndex}">
										 <td class="pageindex">
											<a href="javascript:nPage('${pagebtn.pageIndex}')">${pagebtn.showPageCode}</a>
                               			 </td>
									</c:if>
								</c:forEach>
								
                                <c:if test="${false == PAGEINFO.pDownIsUsed}">
                               		 <td class="pageindexn">
                                    	下一页&gt;
                                	</td>
								</c:if>
								<c:if test="${true == PAGEINFO.pDownIsUsed}">
									<td class="pageindexn">
                                    	<a href="javascript:nextPage()">下一页&gt;</a>
                                	</td>
								</c:if>
                            </tr>
                        </table>
                    </div>                      
					<div class="contract_price_form_buttonrow">
						<input type="button" class="buttonok" value="删除"  onclick="deletePrice()"/>
						&nbsp;&nbsp;
						<input type="button" class="buttonok" value="导出" onclick="batchExport2Xls()"/>
					</div>
					 <!-- 计算用的form -->
				<form id="calpriceform" name="calpriceform" method="post">
					<!-- 集团 -->
					<input type="hidden" id="pk_group_cal" name="pk_group_cal" value="" />
					<!-- 组织 -->
					<input type="hidden" id="pk_org_cal" name="pk_org_cal" value="" />
					<!-- 产品 -->
					<input type="hidden" id="pk_prod_cal" name="pk_prod_cal" value="" />
					<!-- 报价币种 -->
					<input type="hidden" id="pk_currency_cal" name="pk_currency_cal"
						value="" />
					<!-- 报价单位 -->
					<input type="hidden" id="pk_unit_cal" name="pk_unit_cal" value="" />
					<!-- 主单位 -->
					<input type="hidden" id="pk_primary_unit_cal"
						name="pk_primary_unit_cal" value="" />
					<!-- 报价数量 -->
					<input type="hidden" id="amount_cal" name="amount_cal" value="" />
					<!-- 主数量 -->
					<input type="hidden" id="primary_amount_cal"
						name="primary_amount_cal" value="" />
					<!-- 换算率 -->
					<input type="hidden" id="conversion_rate_cal"
						name="conversion_rate_cal" value="" />
					<!-- 扣税类别 -->
					<input type="hidden" id="tax_type_cal" name="tax_type_cal" value="" />
					<!-- 税率 -->
					<input type="hidden" id="tax_rate_cal" name="tax_rate_cal" value="" />
					<!-- 折扣率 -->
					<input type="hidden" id="discount_rate_cal"
						name="discount_rate_cal" value="" />
					<!-- 含税单价 -->
					<input type="hidden" id="has_tax_price_cal"
						name="has_tax_price_cal" value="" />
					<!-- 含税金额 -->
					<input type="hidden" id="has_tax_sum_cal" name="has_tax_sum_cal"
						value="" />
					<!-- 含税净价 -->
					<input type="hidden" id="has_tax_net_price_cal"
						name="has_tax_net_price_cal" value="" />
					<!-- 主含税净价 -->
					<input type="hidden" id="primary_hastax_net_price_cal"
						name="primary_hastax_net_price_cal" value="" />
					<!-- 无税单价 -->
					<input type="hidden" id="no_tax_price_cal" name="no_tax_price_cal"
						value="" />
					<!-- 无税金额 -->
					<input type="hidden" id="no_tax_sum_cal" name="no_tax_sum_cal"
						value="" />
					<!-- 无税净价 -->
					<input type="hidden" id="no_tax_net_price_cal"
						name="no_tax_net_price_cal" value="" />
					<!-- 主无税净价 -->
					<input type="hidden" id="primary_notax_net_price_cal"
						name="primary_notax_net_price_cal" value="" />
					<!-- 价税合计 -->
					<input type="hidden" id="price_tax_sum_cal"
						name="price_tax_sum_cal" value="" />
					<input type="hidden" id="tax_sum_cal" name="tax_sum_cal" value="" />
					<!-- 用于触发计算的字段顺序 -->
					<input type="hidden" id="property_cal" name="property_cal" value="" />
					<!-- 参数字段 -->
					<input type="hidden" id="isTaxPrior" name="isTaxPrior" value="" />
					<!-- 计算行 -->
					<input type="hidden" id="row_no" name="row_no" value=""/>
				</form>           
                 </div>
               </div>
     </body>
</html>
